package com.example.aminsms;



import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.Menu;
import android.widget.EditText;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public void MostrarSMS(View view)
	{
		EditText et1;
		et1=(EditText)findViewById(R.id.editText1);
		Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
		cursor.moveToFirst();
		String msgData= "";
		if (cursor.moveToFirst())
		{
			do
			{
				msgData+= "\n** Mensaje **\n";
			   for(int idx=0; idx<cursor.getColumnCount(); idx++)
			   {
			       msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
			   }
			   msgData += "\n";
			}
			while(cursor.moveToNext());
			cursor.close();
			et1.setText(msgData);
		}
		else
			et1.setText("No hay mensajes en la bandeja de entrada");

	}

}
